package app

type User struct {
	UserId     uint32 `api:"rand" xorm:"pk"`
	UserName   string
	Email      string
	Phone      string
	Password   string `api:"hidden"`
	UserType   string
	Status     string
	Desc       string
	CreateTime uint32 `api:"createtime"`
}

type DeviceGroup struct {
	DeviceGroupId   uint32 `api:"rand" xorm:"pk"`
	DeviceGroupName string
	Desc            string
	DeviceCount     uint32
	ShowIndex       uint32 `api:"createtime"`
	CreateTime      uint32 `api:"createtime"`
}

type Device struct {
	DeviceId      uint32 `api:"rand" xorm:"pk"`
	DeviceGroupId uint32

	Name          string
	Code          string
	Desc          string
	Otg           string
	Ip            string
	Port          string
	Status        string
	LatestConnect uint32 `api:"createtime"`

	ShowIndex  uint32 `api:"createtime"`
	CreateTime uint32 `api:"createtime"`
}

type DeviceWithGroup struct {
	Device          `xorm:"extends"`
	DeviceGroupName string
}

func (DeviceWithGroup) TableName() string {
	return "device"
}

type TaskGroup struct {
	TaskGroupId   uint32 `api:"rand" xorm:"pk"`
	DeviceGroupId uint32
	ProductPath   string

	AppointmentTime int64 // 预约时间
	StopTime        int64 // 超时结束时间
	HoldSec         int
	Retry           int

	Name       string
	Desc       string
	CreateTime uint32 `api:"createtime"`
}

type TaskLog struct {
	TaskLogId   uint64 `api:"rand" xorm:"pk"`
	TaskGroupId uint32

	// 执行设备
	DeviceGroupId   uint32
	DeviceGroupName string
	DeviceId        uint32
	DeviceCode      string
	DeviceName      string

	Status string

	// 任务信息
	Account      string // 逛号
	ProductCode  string
	ProductTitle string
	IsStart      string
	ReleaseTime  string
	Addr         string
	HoldSec      int
	Retry        int
	SendCount    int

	AppointmentTime int64 // 预约时间
	StopTime        int64 // 超时结束时间
	StartTime       int64 // 实际执行时间
	EndTime         int64 // 完成时间
	Img             string

	CreateTime uint32 `api:"createtime"`
}

type Task struct {
	TaskId uint32 `api:"rand" xorm:"pk"`

	ProductPath     string
	DeviceGroupId   uint32
	DeviceGroupName string

	Name    string
	Desc    string
	Status  string
	HoldSec int
	Retry   int

	AppointmentTime uint32 // 预约时间
	StartTime       uint32 // 实际执行时间
	DoneTime        uint32 // 完成时间

	CreateTime uint32 `api:"createtime"`
}

type Result struct {
	ProductId uint32
	TaskId    uint32
	DoneTime  uint32
	ImgUrl    string
	ImgPath   string
}

type Product struct {
	ProductId       uint32 `api:"rand" xorm:"pk"`
	TaskId          uint32 // 对应任务id
	DeviceGroupId   uint32 // 执行分组
	DeviceGroupName string // 执行分组名称

	Account      string // 逛号
	ProductCode  string
	ProductTitle string
	ReleaseTime  string
	IsStart      string
	TaskConfig   string

	CreateTime uint32 `api:"createtime"`
}

type ProductWithGroup struct {
	Product         `xorm:"extends"`
	DeviceGroupName string
}

func (ProductWithGroup) TableName() string {
	return "product"
}

type TaskConfig struct {
	ConfigId   uint32 `api:"rand" xorm:"pk"`
	Name       string
	Config     string
	Desc       string
	IsDefault  string
	ShowIndex  uint32 `api:"createtime"`
	CreateTime uint32 `api:"createtime"`
}
